<template>
  <a-card :bordered="false" class="card-area">
    <!-- 查询区域 11111-->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" :label-col="labelCol" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">

          <a-col :md="10" :sm="10">
            <a-form-item label="选择时间">
              <j-date placeholder="请选择开始日期" class="query-group-cust" v-model="queryParam.beginTime"></j-date>
              <span class="query-group-split-cust"></span>
              <j-date placeholder="请选择结束日期" class="query-group-cust" v-model="queryParam.endTime"></j-date>
            </a-form-item>
          </a-col>
          <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
           <a-col :md="6" :sm="24">
               <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
               <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
           </a-col>
        </span>
        </a-row>
      </a-form>
    </div>
    <a-row>
      <div class="el-row" style="margin-left: -10px; margin-right: -10px;">
        <div class="el-col el-col-6 is-guttered" style="padding-right: 10px; padding-left: 10px;">
          <div class="pb16 grid-content bg-purple"><div>营业总额(元)</div>
            <div class="detail_prici">{{order.realityAmount}}</div></div>
        </div>
        <div class="el-col el-col-6 is-guttered" style="padding-right: 10px; padding-left: 10px;">
          <div class="pb16 grid-content bg-purple">
            <div>预计收入(元)</div>
            <div class="detail_prici">{{order.incomeAmount}}</div>
          </div>
        </div>
        <div class="el-col el-col-6 is-guttered" style="padding-right: 10px; padding-left: 10px;">
          <div class="pb16 grid-content bg-purple">
            <div>有效订单数</div>
            <div class="detail_prici">{{order.realityQty}}</div>
          </div>
        </div>
        <div class="el-col el-col-6 is-guttered" style="padding-right: 10px; padding-left: 10px;">
          <div class="pb16 grid-content bg-purple">
            <div>退款金额(元)</div>
            <div class="detail_prici">{{order.refundAmount}}</div>
          </div>
        </div>
      </div>
    </a-row>

    <!-- 操作按钮区域 -->
    <div style="margin-top: 50px">
      <LineChartMultid title="订单数" :dataSource="barData" :fields="fields"/>
    </div>

    <!-- table区域-begin -->
    <div>


      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">


      </a-table>
    </div>
    <!-- table区域-end -->
  </a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { putAction, getAction, postAction } from '@/api/manage'
import { frozenBatch } from '@/api/api'
import LineChartMultid from '@/components/chart/LineChartMultid'
import JDate from '@/components/jeecg/JDate'
export default {
  name: 'ord_store_memberList',
  mixins: [JeecgListMixin],
  components: {
    LineChartMultid,
    JDate
  },
  data() {
    return {
      description: '餐饮会员信息管理页面',
      labelCol: { style: { width: '110px' } },
      fields:["预计收入","订单量"],
      barData:[],
      // 表头
      columns: [
        {
          title: '有效订单数',
          align: 'center',
          dataIndex: 'realityQty'
        },
        {
          title: '营业总额',
          align: 'center',
          dataIndex: 'incomeAmount'
        },
        {
          title: '退款金额',
          align: 'center',
          dataIndex: 'refundAmount'
        },
        {
          title: '预计收入',
          align: 'center',
          dataIndex: 'realityAmount',
        },
        {
          title: '添加时间',
          align: 'center',
          dataIndex: 'dayMillisecondsTime'
        }
      ],
      url: {
        order: '/store/report/order',
        list:'/store/report/order/page',
        transaction:'/store/report/transaction',
      },
      order:{
        incomeAmount:0.0,
        qty:0,
        refundAmount:0.0,
        refundQty:0,
        realityAmount:0.0,
        realityQty:0,
      },
    }
  },
  created() {
    const that = this
    let ymd = this.getDate2Ymd();
    that.queryParam.beginTime = ymd;
    that.queryParam.endTime = ymd;
    that.searchQuery();
  },
  methods: {
    searchQuery() {
      const that=this;
      var params1={"beginTime":that.queryParam.beginTime,"endTime":that.queryParam.endTime}
      getAction(this.url.order,params1).then((res) => {
        if (res.success) {
          this.order=res.result;
        }
      })
      var params3={"beginTime":that.queryParam.beginTime,"endTime":that.queryParam.endTime}
      getAction(this.url.transaction,params3).then((res) => {
        if (res.success) {
          res.result.forEach((item,index)=>{
            var data={ "type": item.date, "预计收入": item.totalAmount, "订单量":item.qty};
            that.barData.push(data);
          })
        }
      })

      this.loadData(1);
      // 点击查询清空列表选中行
      // https://gitee.com/jeecg/jeecg-boot/issues/I4KTU1
      this.selectedRowKeys = []
      this.selectionRows = []
    },

  }
}
</script>
<style scoped>
.el-row {
  display: flex;
  flex-wrap: wrap;
  position: relative;
  box-sizing: border-box;
}
guttered {
  display: block;
  min-height: 1px;
}
.el-col {
  border-radius: 4px;
}
.el-col-6 {
  max-width: 25%;
  flex: 0 0 25%;
}

.bg-purple {
  background: #f4f4f4;
}
.grid-content {
  padding: 20px;
  border-radius: 4px;
  min-height: 36px;
}
.pb16 {
  padding-bottom: 16px;
}
</style>
